#pragma once
#include <addons\ScreenQuad.h>
#include <lib\container\GridArray.h>

class Gutter : public ds::Node {

struct Level {
	int index;
	char name[32];
	int tiles[84];
};

typedef std::vector<Level*> Levels;

public:
	Gutter(void);
	~Gutter(void);
	void loadTextLevel(int lvl);	
	bool isBlockAvailable(int gx,int gy);
	void markCell(int gx,int gy);
	uint32 getCoverage() const {
		return (uint32)(((float)m_CellCounter / (float)m_Total)*100.0f);
	}
	void update(float elapsed);
	void reset() {
		m_Grid->clear();
		m_Borders->clear();
		m_Selection->clear();
	}
	void loadTextLevelFiles();
	void getLevelNames(std::vector<std::string>& levelNames);
private:
	void loadTextLevel(const std::string& fileName,Level* level);
	bool isAllowed(int gx,int gy);
	bool hasAdjacent(int gx,int gy);
	ds::ScreenQuad* m_Selection;
	ds::ScreenQuad* m_Grid;
	ds::ScreenQuad* m_Borders;
	ds::GridArray<int> m_Tiles;
	ds::GridArray<int> m_Pieces;
	uint32 m_Total;
	uint32 m_CellCounter;
	Levels m_Levels;
};

